home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Src Code / GLCANVAS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  31.0 KB  |  1,178 lines

  1. {******************************************}
  2. {      TeeChart Pro OpenGL Canvas          }
  3. {   Copyright (c) 1998 by David Berneda    }
  4. {         All Rights Reserved              }
  5. {******************************************}
  6. {$I teedefs.inc}
  7. unit GLCanvas;
  8.  
  9. interface
  10.  
  11. uses
  12.   Windows, Messages, SysUtils, Classes, Graphics, OpenGL2, Controls, TeCanvas;
  13.  
  14. type
  15.     GLMat=Array[0..3] of GLFloat;
  16.  
  17.     TGLCanvas = class(TCanvas3D)
  18.     private
  19.       { Private declarations }
  20.       FBackColor     : TColor;
  21.       FBackMode      : TCanvasBackMode;
  22.       FDepth         : Integer;
  23.       FTextAlign     : Integer;
  24.       FUseMaterial   : Boolean;
  25.  
  26.       FWidth         : {$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF};
  27.       FHeight        : {$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF};
  28.       FXCenter       : {$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF};
  29.       FYCenter       : {$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF};
  30.  
  31.       FOnInit        : TNotifyEvent;
  32.  
  33.       { internal }
  34.       TheFontHandle  : Integer;
  35.       FDC            : HDC;
  36.       HRC            : HGLRC;
  37.       Palette        : HPALETTE;
  38.       FontOffset     : Integer;
  39.       FX             : Integer;
  40.       FY             : Integer;
  41.       FZ             : Integer;
  42.       IFontCreated   : Boolean;
  43.  
  44.       Procedure TeeVertex2D(x,y:Integer);
  45.       Procedure TeeVertex3D(x,y,z:Integer);
  46.       Procedure TeeNormal(x,y,z:Integer);
  47.       Procedure SetPenColor;
  48.  
  49.       Procedure InitMatrix;
  50.       Procedure DoProjection;
  51.       Procedure SetMaterial(AColor:TColor);
  52.     protected
  53.       { Protected declarations }
  54.       Procedure InitFont;
  55.     public
  56.       { Public declarations }
  57.       Constructor Create;
  58.       Destructor Destroy; override;
  59.       Procedure Repaint;
  60.  
  61.       { 2d }
  62.       procedure SetPixel(X, Y: Integer; Value: TColor); override;
  63.       Function GetSupports3DText:Boolean; override;
  64.       Function GetSupportsFullRotation:Boolean; override;
  65.       Function GetTextAlign:TCanvasTextAlign; override;
  66.       Function GetUseBuffer:Boolean; override;
  67.       Procedure SetUseBuffer(Value:Boolean); override;
  68.       Function GetHandle:HDC; override;
  69.  
  70.       { 3d }
  71.       procedure SetPixel3D(X,Y,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}; Value: TColor); override;
  72.  
  73.       Procedure SetBackMode(Mode:TCanvasBackMode); override;
  74.       Function GetMonochrome:Boolean; override;
  75.       Procedure SetMonochrome(Value:Boolean); override;
  76.       Procedure SetBackColor(Color:TColor); override;
  77.       Function GetBackMode:TCanvasBackMode; override;
  78.       Function GetBackColor:TColor; override;
  79.       Procedure SetTextAlign(Align:TCanvasTextAlign); override;
  80.  
  81.       procedure Arc(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer); override;
  82.       procedure Draw(X, Y: Integer; Graphic: TGraphic); override;
  83.       procedure EraseBackground(const Rect: TRect); override;
  84.       procedure FillRect(const Rect: TRect); override;
  85.       procedure Frame3D( Rect: TRect; TopColor,BottomColor: TColor;
  86.                          Width: Integer); override;
  87.       procedure Ellipse(X1, Y1, X2, Y2: Integer); override;
  88.       procedure LineTo(X,Y:Integer); override;
  89.       procedure MoveTo(X,Y:Integer); override;
  90.       procedure Pie(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer); override;
  91.       procedure Rectangle(X0,Y0,X1,Y1:Integer); override;
  92.       procedure RoundRect(X1, Y1, X2, Y2, X3, Y3: Integer); override;
  93.       procedure StretchDraw(const Rect: TRect; Graphic: TGraphic); override;
  94.       Procedure TextOut(X,Y:Integer; const Text:String); override;
  95.       Procedure DoRectangle(Const Rect:TRect); override;
  96.       Procedure DoHorizLine(X0,X1,Y:Integer); override;
  97.       Procedure DoVertLine(X,Y0,Y1:Integer); override;
  98.       procedure ClipRectangle(Const Rect:TRect); override;
  99.       procedure ClipCube(Const Rect:TRect; MinZ,MaxZ:Integer); override;
  100.       procedure UnClipRectangle; override;
  101.       Procedure GradientFill( Const Rect:TRect;
  102.                               StartColor,EndColor:TColor;
  103.                               Direction:TGradientDirection); override;
  104.       procedure RotateLabel(x,y:Integer; Const St:String; RotDegree:Integer); override;
  105.       procedure RotateLabel3D(x,y,z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF};
  106.                               Const St:String; RotDegree:Integer); override;
  107.       Procedure Invalidate; override;
  108.       Procedure Line(X0,Y0,X1,Y1:Integer); override;
  109.       Procedure Polygon(const Points: array of TPoint); override;
  110.       { 3d }
  111.       Procedure Calculate2DPosition(Var x,y:Integer; z:Integer); override;
  112.       Function Calculate3DPosition(x,y,z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}):TPoint; override;
  113.       Procedure Projection(MaxDepth:Integer; const Bounds,Rect:TRect); override;
  114.       Function InitWindow( DestCanvas:TCanvas;
  115.                            A3DOptions:TView3DOptions;
  116.                            ABackColor:TColor;
  117.                            Is3D:Boolean;
  118.                            Const UserRect:TRect):TRect; override;
  119.       Procedure ShowImage(DestCanvas,DefaultCanvas:TCanvas; Const UserRect:TRect); override;
  120.       Function ReDrawBitmap:Boolean; override;
  121.       Procedure Arrow( Filled:Boolean;
  122.                        Const FromPoint,ToPoint:TPoint;
  123.                        ArrowWidth,ArrowHeight,Z:Integer); override;
  124.       Procedure Cube(Left,Right,Top,Bottom,Z0,Z1:Integer; DarkSides:Boolean); override;
  125.       procedure Cylinder(Vertical:Boolean; Left,Top,Right,Bottom,Z0,Z1:Integer; DarkCover:Boolean); override;
  126.       procedure EllipseWithZ(X1, Y1, X2, Y2, Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}); override;
  127.       Procedure RectangleZ(Left,Top,Bottom,Z0,Z1:Integer); override;
  128.       Procedure RectangleY(Left,Top,Right,Z0,Z1:Integer); override;
  129.       procedure FrontPlaneBegin; override;
  130.       procedure FrontPlaneEnd; override;
  131.       Procedure HorizLine3D(Left,Right,Y,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}); override;
  132.       procedure LineTo3D(X,Y,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}); override;
  133.       Procedure LineWithZ(X0,Y0,X1,Y1,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}); override;
  134.       procedure MoveTo3D(X,Y,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}); override;
  135.       procedure Pie3D( XCenter,YCenter,XRadius,YRadius,Z0,Z1:Integer;
  136.                        Const StartAngle,EndAngle:Double;
  137.                        DarkSides,DrawSides:Boolean); override;
  138.       procedure Plane3D(Const A,B:TPoint; Z0,Z1:Integer); override;
  139.       procedure PlaneWithZ(P1,P2,P3,P4:TPoint; Z:Integer); override;
  140.       procedure PlaneFour3D(Points:TFourPoints; Z0,Z1:Integer); override;
  141.       procedure PolygonWithZ(const Points: array of TPoint; Z:Integer);
  142.       procedure Pyramid(Vertical:Boolean; Left,Top,Right,Bottom,z0,z1:Integer; DarkSides:Boolean); override;
  143.       Procedure RectangleWithZ(Const Rect:TRect; Z:Integer); override;
  144.       Procedure TextOut3D(X,Y,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}; const Text:String); override;
  145.       procedure TriangleWithZ(Const P1,P2,P3:TPoint; Z:Integer); override;
  146.       Procedure VertLine3D(X,Top,Bottom,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}); override;
  147.       Procedure ZLine3D(X,Y,Z0,Z1:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}); override;
  148.  
  149.       procedure Sphere(x,y,z,Radius:Integer);
  150.  
  151.       property OnInit:TNotifyEvent read FOnInit write FOnInit;
  152.       property UseMaterial:Boolean read FUseMaterial write FUseMaterial;
  153.     published
  154.     end;
  155.  
  156. Procedure ColorToGL(AColor:TColor; Var C:GLMat);
  157.  
  158. implementation
  159.  
  160. Function MinInteger(a,b:Integer):Integer;
  161. begin
  162.   if a>b then result:=b else result:=a;
  163. end;
  164.  
  165. Procedure ColorToGL(AColor:TColor; Var C:GLMat);
  166. begin
  167.   AColor:=ColorToRGB(AColor);
  168.   C[0]:=(1+GetRValue(AColor))/128.0-1.0;
  169.   C[1]:=(1+GetGValue(AColor))/128.0-1.0;
  170.   C[2]:=(1+GetBValue(AColor))/128.0-1.0;
  171.   C[3]:=1;
  172. end;
  173.  
  174. { TGLCanvas }
  175. Constructor TGLCanvas.Create;
  176. begin
  177.   inherited Create;
  178.   IFontCreated:=False;
  179.   FX:=0;
  180.   FY:=0;
  181.   FZ:=0;
  182. //  FPerspective:=50;
  183.   TheFontHandle:=-1;
  184.   FTextAlign:=TA_LEFT;
  185. end;
  186.  
  187. Destructor TGLCanvas.Destroy;
  188. begin
  189.   wglMakeCurrent(0, 0);
  190.   wglDeleteContext(hrc);
  191.   if Palette<>0 then DeleteObject(Palette);
  192.   inherited Destroy;
  193. end;
  194.  
  195. Procedure TGLCanvas.SetMaterial(AColor:TColor);
  196. var tmp:GLMat;
  197. begin
  198.   ColorToGL(AColor,tmp);
  199.   if FUseMaterial then
  200.      glMaterialfv(GL_FRONT{_AND_BACK}, GL_AMBIENT{_AND_DIFFUSE}, @tmp)
  201.   else
  202.      glColor3f(tmp[0],tmp[1],tmp[2]);
  203. end;
  204.  
  205. Procedure TGLCanvas.Calculate2DPosition(Var x,y:Integer; z:Integer);
  206. begin { nothing yet }
  207. end;
  208.  
  209. Function TGLCanvas.Calculate3DPosition(x,y,z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}):TPoint;
  210. begin
  211.   result:=Point(x,y);
  212. end;
  213.  
  214. Procedure TGLCanvas.Projection(MaxDepth:Integer; const Bounds,Rect:TRect);
  215. begin
  216.   RectSize(Bounds,FWidth,FHeight);
  217.   RectCenter(Rect,FXCenter,FYCenter);
  218.   FDepth:=MaxDepth;
  219.   DoProjection;
  220.   InitMatrix;
  221. end;
  222.  
  223. Procedure TGLCanvas.InitMatrix;
  224. Const Scale=1.0/100.0;
  225. var B:GLMat;
  226. begin
  227.   ColorToGL(FBackColor,B);
  228.   glClearColor(B[0]/2.0+0.5,B[1]/2.0+0.5,B[2]/2.0+0.5,1.0);
  229.   glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  230.  
  231.   glMatrixMode(GL_MODELVIEW);
  232.   glLoadIdentity;
  233.   if Assigned(FOnInit) then FOnInit(Self);
  234.  
  235.   glScalef(Scale,Scale,Scale);
  236.   With View3DOptions do
  237.   begin
  238.     glTranslatef(0,0,-40000.0/Zoom);
  239.     glRotatef(Tilt, 0, 0, 1);
  240.     glRotatef(-Elevation, 1, 0, 0);
  241.     glRotatef(Rotation, 0, 1, 0);
  242.     glTranslatef(HorizOffset,0,0);
  243.     glTranslatef(-FXCenter,0,0);
  244.     glTranslatef(0,FYCenter-VertOffset,0);
  245.   end;
  246. end;
  247.  
  248. Procedure TGLCanvas.TeeVertex2D(x,y:Integer);
  249. begin
  250.   glVertex2i(x,-y);
  251. end;
  252.  
  253. Procedure TGLCanvas.TeeVertex3D(x,y,z:Integer);
  254. begin
  255.   glVertex3i(x,-y,-z);
  256. end;
  257.  
  258. Procedure TGLCanvas.TeeNormal(x,y,z:Integer);
  259. begin
  260.   if y<>0 then y:=-y;
  261.   if (x=0) and (y=0) and (z=0) then z:=1;
  262.   glNormal3i(x,y,-z);
  263. end;
  264.  
  265. Procedure TGLCanvas.Cube(Left,Right,Top,Bottom,Z0,Z1:Integer; DarkSides:Boolean);
  266. var x0f,y0f,z0f,x1f,y1f,z1f:Integer;
  267. begin
  268.   x0f:= Left;
  269.   y0f:=-Top;
  270.   z0f:=-z0;
  271.   x1f:= Right;
  272.   y1f:=-Bottom;
  273.   z1f:=-z1;
  274.   if Brush.Style<>bsClear then
  275.   begin
  276.     glBegin(GL_QUADS);
  277.     SetMaterial(Brush.Color);
  278.       TeeNormal(0,0,z0);
  279.        glVertex3i( x0f, y0f, z0f);
  280.        glVertex3i( x1f, y0f, z0f);
  281.        glVertex3i( x1f, y1f, z0f);
  282.        glVertex3i( x0f, y1f, z0f);
  283.       TeeNormal( 0, 0, z1);
  284.        glVertex3i( x0f,  y0f, z1f);
  285.        glVertex3i( x0f,  y1f, z1f);
  286.        glVertex3i( x1f,  y1f, z1f);
  287.        glVertex3i( x1f,  y0f, z1f);
  288.       TeeNormal(Right,  0,  0);
  289.        glVertex3i( x1f, y0f, z0f);
  290.        glVertex3i( x1f, y0f, z1f);
  291.        glVertex3i( x1f, y1f, z1f);
  292.        glVertex3i( x1f, y1f, z0f);
  293.       TeeNormal(Left,  0,  0);
  294.        glVertex3i( x0f, y0f, z0f);
  295.        glVertex3i( x0f, y1f, z0f);
  296.        glVertex3i( x0f, y1f, z1f);
  297.        glVertex3i( x0f, y0f, z1f);
  298.       TeeNormal( 0, Top,  0);
  299.        glVertex3i( x1f, y0f, z1f);
  300.        glVertex3i( x1f, y0f, z0f);
  301.        glVertex3i( x0f, y0f, z0f);
  302.        glVertex3i( x0f, y0f, z1f);
  303.       TeeNormal( 0, Bottom,  0);
  304.        glVertex3i( x1f, y1f, z1f);
  305.        glVertex3i( x0f, y1f, z1f);
  306.        glVertex3i( x0f, y1f, z0f);
  307.        glVertex3i( x1f, y1f, z0f);
  308.     glEnd;
  309.   end;
  310.   if Pen.Style<>psClear then
  311.   begin
  312.     SetPenColor;
  313.     glBegin(GL_LINE_LOOP);
  314.       TeeNormal(0,0,z0);
  315.       glVertex3i( x0f{-1}, y0f{-1}, z0f{-1});
  316.       glVertex3i( x1f{+1}, y0f{-1}, z0f{-1});
  317.       glVertex3i( x1f{+1}, y1f{+1}, z0f{-1});
  318.       glVertex3i( x0f{-1}, y1f{+1}, z0f{-1});
  319.     glEnd;
  320.  
  321.     glBegin(GL_LINE_LOOP);
  322.       TeeNormal(0,0,z1);
  323.        glVertex3i( x0f,  y0f, z1f);
  324.        glVertex3i( x0f,  y1f, z1f);
  325.        glVertex3i( x1f,  y1f, z1f);
  326.        glVertex3i( x1f,  y0f, z1f);
  327.     glEnd;
  328.  
  329.     glBegin(GL_LINE_LOOP);
  330.       TeeNormal(Right,  0,  0);
  331.        glVertex3i( x1f, y0f, z0f);
  332.        glVertex3i( x1f, y0f, z1f);
  333.        glVertex3i( x1f, y1f, z1f);
  334.        glVertex3i( x1f, y1f, z0f);
  335.     glEnd;
  336.  
  337.     glBegin(GL_LINE_LOOP);
  338.       TeeNormal(Left,  0,  0);
  339.        glVertex3i( x0f, y0f, z0f);
  340.        glVertex3i( x0f, y1f, z0f);
  341.        glVertex3i( x0f, y1f, z1f);
  342.        glVertex3i( x0f, y0f, z1f);
  343.     glEnd;
  344.  
  345.     glBegin(GL_LINE_LOOP);
  346.       TeeNormal( 0, Top,  0);
  347.        glVertex3i( x1f, y0f, z1f);
  348.        glVertex3i( x1f, y0f, z0f);
  349.        glVertex3i( x0f, y0f, z0f);
  350.        glVertex3i( x0f, y0f, z1f);
  351.     glEnd;
  352.  
  353.     glBegin(GL_LINE_LOOP);
  354.       TeeNormal( 0, Bottom,  0);
  355.        glVertex3i( x1f, y1f, z1f);
  356.        glVertex3i( x0f, y1f, z1f);
  357.        glVertex3i( x0f, y1f, z0f);
  358.        glVertex3i( x1f, y1f, z0f);
  359.     glEnd;
  360.   end;
  361. end;
  362.  
  363. {procedure SetDCPixelFormat(DC:HDC; Var Palette:HPalette; ToBitmap:Boolean); forward;}
  364.  
  365. type PointFloat=record x,y:Double; end;
  366. {     GLYPHMETRICSFLOAT=record
  367.        gmfBlackBoxX,
  368.        gmfBlackBoxY:Double;
  369.        gmfptGlyphOrigin:PointFloat;
  370.        gmfCellIncX,
  371.        gmfCellIncY:Double;
  372.      end;}
  373.  
  374. Procedure TGLCanvas.InitFont;
  375. var Old,hFont:THandle;
  376. //    agmf:Array[0..255] of GLYPHMETRICSFLOAT ;
  377.   {$IFNDEF D2C1}
  378.     FontMode:Integer;
  379.   {$ENDIF}
  380. begin
  381.   hFont := CreateFont(8, 0, 0, 0, {FW_THIN}FW_DONTCARE,
  382.               0, 0, 0, ANSI_CHARSET,
  383.               OUT_DEFAULT_PRECIS,
  384.                       CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY{DRAFT_QUALITY},
  385.               DEFAULT_PITCH or FF_DONTCARE{FIXED_PITCH or FF_MODERN},
  386.                       'Arial');
  387.  
  388.   Old:=SelectObject (FDC, hFont);
  389.   fontOffset:=1000;
  390.  
  391.   glDeleteLists(fontOffset,128-32+1);
  392.  
  393.   {$IFNDEF D2C1}
  394. //  FontMode:=WGL_FONT_POLYGONS;
  395.   FontMode:=WGL_FONT_LINES;
  396.   wglUseFontOutlines( FDC,32, 128-32+1,fontOffset,20.90,0,FontMode,nil{@agmf});
  397. //  wglUseFontBitmaps(FDC,32,128-32+1,fontoffset);
  398.   {$ENDIF}
  399.   DeleteObject(SelectObject(FDC,Old));
  400.   IFontCreated:=True;
  401. end;
  402.  
  403. Function TGLCanvas.InitWindow( DestCanvas:TCanvas;
  404.                                A3DOptions:TView3DOptions;
  405.                                ABackColor:TColor;
  406.                                Is3D:Boolean;
  407.                                Const UserRect:TRect):TRect;
  408. begin
  409.   if View3DOptions<>A3DOptions then
  410.   begin
  411.     View3DOptions:=A3DOptions;
  412.     FDC := GetDC((View3DOptions.Parent as TWinControl).Handle);
  413.     InitOpenGL;
  414.     hrc:=CreateRenderingContext(FDC,[opDoubleBuffered],24,0);
  415.     ActivateRenderingContext(FDC,HRC);
  416.   end;
  417.   FX:=0;
  418.   FY:=0;
  419.   SetCanvas(DestCanvas);
  420.  
  421.   glEnable(GL_DITHER);
  422. //    glEnable(GL_LINE_SMOOTH);
  423.   glEnable(GL_AUTO_NORMAL);
  424.   glEnable(GL_NORMALIZE);
  425.   glEnable(GL_DEPTH_TEST);
  426.   glDepthFunc(GL_LEQUAL);
  427.  
  428. //  glEnable(GL_POLYGON_OFFSET_LINE);
  429. //  glPolygonOffset(2,2);
  430.  
  431.   FBackColor:=ABackColor;
  432.   result:=UserRect;
  433. end;
  434.  
  435. Procedure TGLCanvas.DoProjection;
  436. const FarZ=3000;
  437. begin
  438.   glViewport(0, 0, FWidth, FHeight);
  439.   glMatrixMode(GL_PROJECTION);
  440.   glLoadIdentity;
  441.  
  442.   gluPerspective(45,    // Field-of-view angle
  443.                  FWidth/FHeight,  // Aspect ratio of viewing volume
  444.                  0.1,               // Distance to near clipping plane
  445.                  FarZ);           // Distance to far clipping plane
  446. end;
  447.  
  448. Procedure TGLCanvas.ShowImage(DestCanvas,DefaultCanvas:TCanvas; Const UserRect:TRect);
  449. begin
  450.   glFlush;
  451.   SwapBuffers(FDC);
  452. end;
  453.  
  454. Function TGLCanvas.ReDrawBitmap:Boolean;
  455. begin
  456.   result:=False;
  457. end;
  458.  
  459. procedure TGLCanvas.Rectangle(X0,Y0,X1,Y1:Integer);
  460. begin
  461.   if Brush.Style<>bsClear then FillRect(Rect(X0,Y0,X1,Y1));
  462.   if Pen.Style<>psClear then
  463.   begin
  464.     glBegin(GL_LINE_LOOP);
  465.     glNormal3i(0,0,1);
  466.     SetPenColor;
  467.     TeeVertex2D(X0,Y0);
  468.     TeeVertex2D(X1,Y0);
  469.     TeeVertex2D(X1,Y1);
  470.     TeeVertex2D(X0,Y1);
  471.     glEnd;
  472.   end;
  473. end;
  474.  
  475. procedure TGLCanvas.SetTextAlign(Align:Integer);
  476. begin
  477.   FTextAlign:=Align;
  478. end;
  479.  
  480. procedure TGLCanvas.MoveTo(X, Y: Integer);
  481. begin
  482.   FX:=X;
  483.   FY:=Y;
  484. end;
  485.  
  486. procedure TGLCanvas.Pyramid(Vertical:Boolean; Left,Top,Right,Bottom,z0,z1:Integer; DarkSides:Boolean);
  487. begin
  488.   if Brush.Style<>bsClear then
  489.   begin
  490.     glBegin(GL_TRIANGLE_FAN);
  491.     SetMaterial(Brush.Color);
  492.     TeeNormal(0,0,z0);
  493.     TeeVertex3D(Left,Bottom,z0);
  494.     TeeVertex3D(Right,Bottom,z0);
  495.     TeeVertex3D((Left+Right) div 2,Top,(z0+z1) div 2);
  496.     TeeVertex3D(Right,Bottom,z1);
  497.     TeeVertex3D(Right,Bottom,z0);
  498.     glEnd;
  499.   end;
  500.   if Pen.Style<>psClear then
  501.   begin
  502.     glBegin(GL_LINE_STRIP);
  503.     SetPenColor;
  504.     TeeNormal(0,0,z0);
  505.     TeeVertex3D(Left,Bottom,z0);
  506.     TeeVertex3D(Right,Bottom,z0);
  507.     TeeVertex3D((Left+Right) div 2,Top,(z0+z1) div 2);
  508.     TeeVertex3D(Right,Bottom,z1);
  509.     glEnd;
  510.   end;
  511. end;
  512.  
  513. procedure TGLCanvas.Cylinder(Vertical:Boolean; Left,Top,Right,Bottom,Z0,Z1:Integer; DarkCover:Boolean);
  514. Var c:PGLUQuadricObj;
  515.     tmpSize,Radius:Integer;
  516. begin
  517.   glPushMatrix;
  518.   if Vertical then
  519.   begin
  520.     Radius:=MinInteger((Right-Left) div 2,(Z1-Z0) div 2);
  521.     glTranslatef(Left+(Right-Left) div 2,-Top,-z0-Radius);
  522.     tmpSize:=Bottom-Top;
  523.     glRotatef(90,1,0,0);
  524.   end
  525.   else
  526.   begin
  527.     Radius:=MinInteger((Bottom-Top) div 2,(Z1-Z0) div 2);
  528.     glTranslatef(Left,-Top+(Bottom-Top) div 2,-z0-Radius);
  529.     tmpSize:=Right-Left;
  530.     glRotatef(90,0,1,0);
  531.   end;
  532.   SetMaterial(Brush.Color);
  533.   c:=gluNewQuadric;
  534.   gluCylinder(c,Radius,Radius,tmpSize,18,6);
  535.   gluDeleteQuadric(c);
  536.   c:=gluNewQuadric;
  537.   gluDisk(c,0,Radius,18,6);
  538.   gluDeleteQuadric(c);
  539.   glPopMatrix;
  540. end;
  541.  
  542. procedure TGLCanvas.Sphere(x,y,z,Radius:Integer);
  543. Var c:PGLUQuadricObj;
  544. begin
  545.   glPushMatrix;
  546.   c:=gluNewQuadric;
  547.   TeeNormal(0, 0, 1);
  548.    glTranslatef(x,y,z);
  549.    SetMaterial(Brush.Color);
  550.    gluSphere(c,Radius,18,18);
  551.    gluDeleteQuadric(c);
  552.   glPopMatrix;
  553. end;
  554.  
  555. procedure TGLCanvas.SetPenColor;
  556. begin
  557.   SetMaterial(Pen.Color);
  558. //  glLineStipple(1, 31234);  {<-- mask =psdot, psdash, etc }
  559.   glLineWidth( Pen.Width );
  560. end;
  561.  
  562. procedure TGLCanvas.LineTo(X, Y: Integer);
  563. begin
  564.   glBegin(GL_LINES);
  565.     SetPenColor;
  566.     TeeVertex2D(FX,FY);
  567.     TeeVertex2D(X,Y);
  568.   glEnd;
  569.   FX:=X;
  570.   FY:=Y;
  571. end;
  572.  
  573. procedure TGLCanvas.ClipRectangle(Const Rect:TRect);
  574. begin
  575. end;
  576.  
  577. procedure TGLCanvas.ClipCube(Const Rect:TRect; MinZ,MaxZ:Integer);
  578. begin
  579. end;
  580.  
  581. procedure TGLCanvas.UnClipRectangle;
  582. begin
  583. end;
  584.  
  585. function TGLCanvas.GetBackColor:TColor;
  586. begin
  587.   result:=clWhite;
  588. end;
  589.  
  590. procedure TGLCanvas.SetBackColor(Color:TColor);
  591. begin
  592. end;
  593.  
  594. procedure TGLCanvas.SetBackMode(Mode:TCanvasBackMode);
  595. begin
  596. end;
  597.  
  598. Function TGLCanvas.GetMonochrome:Boolean;
  599. begin
  600.   result:=False;
  601. end;
  602.  
  603. Procedure TGLCanvas.SetMonochrome(Value:Boolean);
  604. begin
  605. end;
  606.  
  607. procedure TGLCanvas.StretchDraw(const Rect: TRect; Graphic: TGraphic);
  608. begin
  609. end;
  610.  
  611. procedure TGLCanvas.Draw(X, Y: Integer; Graphic: TGraphic);
  612. begin
  613. end;
  614.  
  615. Procedure TGLCanvas.GradientFill( Const Rect:TRect;
  616.                                   StartColor,EndColor:TColor;
  617.                                   Direction:TGradientDirection);
  618. begin
  619.   { temporary solution }
  620.   SetMaterial(StartColor);
  621.   DoRectangle(Rect);
  622. end;
  623.  
  624. Procedure TGLCanvas.RectangleY(Left,Top,Right,Z0,Z1:Integer);
  625. begin
  626.   if Brush.Style<>bsClear then
  627.   begin
  628.     glBegin(GL_QUADS);
  629.     TeeNormal(0,Top,0);
  630.     SetMaterial(Brush.Color);
  631.     TeeVertex3D(Left, Top,Z0);
  632.     TeeVertex3D(Right,Top,Z0);
  633.     TeeVertex3D(Right,Top,Z1);
  634.     TeeVertex3D(Left, Top,Z1);
  635.     glEnd;
  636.   end;
  637.   if Pen.Style<>psClear then
  638.   begin
  639.     glBegin(GL_LINE_LOOP);
  640.     TeeNormal( 0, Top, 0);
  641.     SetPenColor;
  642.     TeeVertex3D(Left, Top,Z0);
  643.     TeeVertex3D(Right,Top,Z0);
  644.     TeeVertex3D(Right,Top,Z1);
  645.     TeeVertex3D(Left, Top,Z1);
  646.     glEnd;
  647.   end;
  648. end;
  649.  
  650. Procedure TGLCanvas.RectangleWithZ(Const Rect:TRect; Z:Integer);
  651. begin
  652.   With Rect do
  653.   begin
  654.     if Pen.Style<>psClear then
  655.     begin
  656.       glBegin(GL_LINE_LOOP);
  657.       TeeNormal( 0,  0, Z);
  658.       SetPenColor;
  659.       TeeVertex3D(Left, Top,Z);
  660.       TeeVertex3D(Right,Top,Z);
  661.       TeeVertex3D(Right,Bottom,Z);
  662.       TeeVertex3D(Left, Bottom,Z);
  663.       glEnd;
  664.     end;
  665.     if Brush.Style<>bsClear then
  666.     begin
  667.       glBegin(GL_QUADS);
  668.       TeeNormal( 0,  0, Z);
  669.       SetMaterial(Brush.Color);
  670.       TeeVertex3D(Left, Top,Z);
  671.       TeeVertex3D(Left, Bottom,Z);
  672.       TeeVertex3D(Right,Bottom,Z);
  673.       TeeVertex3D(Right,Top,Z);
  674.       glEnd;
  675.     end;
  676.   end;
  677. end;
  678.  
  679. Procedure TGLCanvas.RectangleZ(Left,Top,Bottom,Z0,Z1:Integer);
  680. begin
  681.   if Pen.Style<>psClear then
  682.   begin
  683.     glBegin(GL_LINE_LOOP);
  684.     TeeNormal( Left,  0, 0);
  685.     SetPenColor;
  686.     TeeVertex3D(Left,Top,Z0);
  687.     TeeVertex3D(Left,Bottom,Z0);
  688.     TeeVertex3D(Left,Bottom,Z1);
  689.     TeeVertex3D(Left,Top,Z1);
  690.     glEnd;
  691.   end;
  692.   if Brush.Style<>bsClear then
  693.   begin
  694.     glBegin(GL_QUADS);
  695.     TeeNormal(Left,  0, 0);
  696.     SetMaterial(Brush.Color);
  697.     TeeVertex3D(Left,Top,Z0);
  698.     TeeVertex3D(Left,Bottom,Z0);
  699.     TeeVertex3D(Left,Bottom,Z1);
  700.     TeeVertex3D(Left,Top,Z1);
  701.     glEnd;
  702.   end;
  703. end;
  704.  
  705. procedure TGLCanvas.FillRect(const Rect: TRect);
  706. begin
  707.   if Brush.Style<>bsClear then
  708.   begin
  709.     glBegin(GL_POLYGON);
  710.       TeeNormal( 0, 0, 1);
  711.       SetMaterial(Brush.Color);
  712.       With Rect do
  713.       begin
  714.         TeeVertex2D(Right,Bottom);
  715.         TeeVertex2D(Right,Top);
  716.         TeeVertex2D(Left, Top);
  717.         TeeVertex2D(Left, Bottom);
  718.       end;
  719.     glEnd;
  720.   end;
  721. end;
  722.  
  723. procedure TGLCanvas.Frame3D( Rect: TRect; TopColor, BottomColor: TColor;
  724.                              Width: Integer);
  725. begin
  726.   FillRect(Rect);
  727. end;
  728.  
  729. procedure TGLCanvas.Ellipse(X1, Y1, X2, Y2: Integer);
  730. begin
  731.   EllipseWithZ(X1,Y1,X2,Y2,0);
  732. end;
  733.  
  734. procedure TGLCanvas.EllipseWithZ(X1, Y1, X2, Y2, Z: {$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF});
  735. Const PiStep=pi/10.0;
  736. var t,XC,YC,XR,YR:Integer;
  737.     tmpSin,tmpCos:Extended;
  738. begin
  739.   XR:=(X2-X1) div 2;
  740.   YR:=(Y2-Y1) div 2;
  741.   XC:=(X1+X2) div 2;
  742.   YC:=(Y1+Y2) div 2;
  743.   if Pen.Style<>psClear then
  744.   begin
  745.     glBegin(GL_LINE_LOOP);
  746.     SetPenColor;
  747.     TeeNormal(0,0,z);
  748.     for t:=0 to 18 do
  749.     begin
  750.       SinCos(t*piStep,tmpSin,tmpCos);
  751.       TeeVertex3D(XC+Trunc(XR*tmpSin),YC+Trunc(YR*tmpCos),Z);
  752.     end;
  753.     glEnd;
  754.   end;
  755.   if Brush.Style<>bsClear then
  756.   begin
  757.     glBegin(GL_TRIANGLE_FAN);
  758.     SetMaterial(Brush.Color);
  759.     TeeNormal(0,0,z);
  760.     TeeVertex3D(XC,YC,Z);
  761.     for t:=0 to 20 do
  762.     begin
  763.       SinCos(t*piStep,tmpSin,tmpCos);
  764.       TeeVertex3D(XC+Trunc(XR*tmpSin),YC+Trunc(YR*tmpCos),Z);
  765.     end;
  766.     glEnd;
  767.   end;
  768. end;
  769.  
  770. procedure TGLCanvas.FrontPlaneBegin;
  771. Const Scale=1.0/100.0;
  772. begin
  773.   glPushMatrix;
  774.   glLoadIdentity;
  775.   glScalef(Scale,Scale,Scale);
  776.   glTranslatef(-FXCenter,FYCenter,0);
  777. end;
  778.  
  779. procedure TGLCanvas.FrontPlaneEnd;
  780. begin
  781.   glPopMatrix;
  782. end;
  783.  
  784. procedure TGLCanvas.SetPixel3D(X,Y,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}; Value: TColor);
  785. begin
  786.   if Pen.Style<>psClear then
  787.   begin
  788.     glBegin(GL_POINT);
  789.     Pen.Color:=Value;
  790.     SetPenColor;
  791.     TeeVertex3D(X,Y,Z);
  792.     glEnd;
  793.   end;
  794. end;
  795.  
  796. procedure TGLCanvas.SetPixel(X, Y: Integer; Value: TColor);
  797. begin
  798.   if Pen.Style<>psClear then
  799.   begin
  800.     glBegin(GL_POINT);
  801.     Pen.Color:=Value;
  802.     SetPenColor;
  803.     TeeVertex2D(X,Y);
  804.     glEnd;
  805.   end;
  806. end;
  807.  
  808. procedure TGLCanvas.Arc(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer);
  809. begin
  810. //  gluPartialDisk
  811. end;
  812.  
  813. procedure TGLCanvas.Pie(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer);
  814. begin
  815. //  gluPartialDisk
  816. end;
  817.  
  818. procedure TGLCanvas.Pie3D( XCenter,YCenter,XRadius,YRadius,Z0,Z1:Integer;
  819.                            Const StartAngle,EndAngle:Double;
  820.                            DarkSides,DrawSides:Boolean);
  821.  
  822. Var piStep:Double;
  823.     tmpSin,tmpCos:Extended;
  824.     Radius:Integer;
  825.  
  826.   Function ToDegree(Const Value:Double):Double;
  827.   begin
  828.     result:=Value*180.0/pi;
  829.   end;
  830.  
  831.   Procedure DrawPieSlice(z:Integer);
  832.  
  833.     Procedure DrawSlice;
  834.     var t:Integer;
  835.     begin
  836.       TeeNormal(0,0,z);
  837.       TeeVertex3D(0,0,z);
  838.       for t:=0 to 20 do
  839.       begin
  840.         SinCos(StartAngle+(t*piStep),tmpSin,tmpCos);
  841.         TeeVertex3D(Trunc(Radius*tmpSin),Trunc(Radius*tmpCos),z);
  842.       end;
  843.     end;
  844.  
  845.   begin
  846.     if Pen.Style<>psClear then
  847.     begin
  848.       glBegin(GL_LINE_LOOP);
  849.       SetPenColor;
  850.       DrawSlice;
  851.       glEnd;
  852.     end;
  853.     if Brush.Style<>bsClear then
  854.     begin
  855.       glBegin(GL_TRIANGLE_FAN);
  856.       SetMaterial(Brush.Color);
  857.       DrawSlice;
  858.       glEnd;
  859.     end;
  860.   end;
  861.  
  862.   Procedure DrawCover;
  863.   var t,x,y:Integer;
  864.   begin
  865.     glBegin(GL_QUAD_STRIP);
  866.     SetMaterial(Brush.Color);
  867.     for t:=0 to 20 do
  868.     begin
  869.       SinCos(StartAngle+(t*piStep),tmpSin,tmpCos);
  870.       X:=Trunc(Radius*tmpSin);
  871.       Y:=Trunc(Radius*tmpCos);
  872.       TeeVertex3D(X,Y,0);
  873.       TeeVertex3D(X,Y,z1-z0);
  874.     end;
  875.     glEnd;
  876.   end;
  877.  
  878. begin
  879.   glPushMatrix;
  880.   glTranslatef(XCenter,-YCenter,0);
  881.   Radius:=MaxLong(XRadius,YRadius);
  882.   piStep:=(EndAngle-StartAngle)/20.0;
  883.   DrawCover;
  884.   if DrawSides then
  885.   begin
  886.     SinCos(StartAngle,tmpSin,tmpCos);
  887.     Plane3D(Point(0,0),Point(Round(Radius*tmpSin),Round(Radius*tmpCos)),Z0,Z1);
  888.     SinCos(EndAngle,tmpSin,tmpCos);
  889.     Plane3D(Point(0,0),Point(Round(Radius*tmpSin),Round(Radius*tmpCos)),Z0,Z1);
  890.   end;
  891.   DrawPieSlice(z0);
  892.   DrawPieSlice(z1);
  893.   glPopMatrix;
  894. end;
  895.  
  896. procedure TGLCanvas.Polygon(const Points: array of TPoint);
  897. begin
  898.   PolygonWithZ(Points,0);
  899. end;
  900.  
  901. procedure TGLCanvas.PlaneFour3D(Points:TFourPoints; Z0,Z1:Integer);
  902. begin
  903.   if Pen.Style<>psClear then
  904.   begin
  905.     glBegin(GL_LINE_LOOP);
  906.     SetPenColor;
  907.     With Points[0] do TeeVertex3D(x,y,z0);
  908.     With Points[1] do TeeVertex3D(x,y,z0);
  909.     With Points[2] do TeeVertex3D(x,y,z1);
  910.     With Points[3] do TeeVertex3D(x,y,z1);
  911.     glEnd;
  912.   end;
  913.   if Brush.Style<>bsClear then
  914.   begin
  915.     glBegin(GL_POLYGON);
  916.     TeeNormal(0,0,z0);
  917.     SetMaterial(Brush.Color);
  918.     With Points[0] do TeeVertex3D(x,y,z0);
  919.     With Points[1] do TeeVertex3D(x,y,z0);
  920.     With Points[2] do TeeVertex3D(x,y,z1);
  921.     With Points[3] do TeeVertex3D(x,y,z1);
  922.     glEnd;
  923.   end;
  924. end;
  925.  
  926. procedure TGLCanvas.RoundRect(X1, Y1, X2, Y2, X3, Y3: Integer);
  927. begin
  928.   Rectangle(X1,Y1,X2,Y2);
  929. end;
  930.  
  931. Procedure TGLCanvas.Repaint;
  932. begin
  933.   if Assigned(View3DOptions) then View3DOptions.Repaint;
  934. end;
  935.  
  936. Procedure TGLCanvas.Invalidate;
  937. begin { nothing to do }
  938. end;
  939.  
  940. Procedure TGLCanvas.TextOut3D(X,Y,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}; const Text:String);
  941. var tmp:TSize;
  942.     tmpLength:Integer;
  943.     s:String;
  944. begin
  945.   glPushMatrix;
  946.   if not IFontCreated then InitFont;
  947.  
  948.   glListBase(FontOffset-32);
  949.  
  950.   s:=Text;
  951.   tmpLength:=Length(s);
  952.   GetTextExtentPoint(FDC, PChar(s), tmpLength, tmp);
  953.   if (FTextAlign and TA_CENTER)=TA_CENTER then
  954.     x:=x-(tmp.Cx div 2)
  955.   else
  956.   if (FTextAlign and TA_RIGHT)=TA_RIGHT then
  957.     x:=x-2*(tmp.Cx div 3);
  958.  
  959.   if (FTextAlign and TA_BOTTOM)<>TA_BOTTOM then
  960.     y:=y+2*(tmp.Cy div 3);
  961.  
  962.   glTranslatef( x,-y,-z+1);
  963.   glScalef(Font.Size*1.5,Font.Size*1.5,1);
  964.  
  965.   SetMaterial(Font.Color);
  966.   glCallLists(1+tmpLength, GL_UNSIGNED_BYTE, PChar(Text));
  967.   glPopMatrix;
  968. end;
  969.  
  970. Procedure TGLCanvas.TextOut(X,Y:Integer; const Text:String);
  971. begin
  972.   TextOut3D(x,y,0,Text);
  973. end;
  974.  
  975. procedure TGLCanvas.MoveTo3D(X,Y,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF});
  976. begin
  977.   FX:=X;
  978.   FY:=Y;
  979.   FZ:=Z;
  980. end;
  981.  
  982. procedure TGLCanvas.LineTo3D(X,Y,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF});
  983. begin
  984.   glBegin(GL_LINES);
  985.     SetPenColor;
  986.     TeeVertex3D(FX,FY,FZ);
  987.     TeeVertex3D(x,y,z);
  988.   glEnd;
  989.   FX:=X;
  990.   FY:=Y;
  991.   FZ:=Z;
  992. end;
  993.  
  994. procedure TGLCanvas.PlaneWithZ(P1,P2,P3,P4:TPoint; Z:Integer);
  995. begin
  996.   if Pen.Style<>psClear then
  997.   begin
  998.     glBegin(GL_LINE_LOOP);
  999.     SetPenColor;
  1000.     TeeNormal(0,0,z);
  1001.     TeeVertex3D(P1.X,P1.Y,Z);
  1002.     TeeVertex3D(P2.X,P2.Y,Z);
  1003.     TeeVertex3D(P3.X,P3.Y,Z);
  1004.     TeeVertex3D(P4.X,P4.Y,Z);
  1005.     TeeVertex3D(P1.X,P1.Y,Z);
  1006.     glEnd;
  1007.   end;
  1008.   if Brush.Style<>bsClear then
  1009.   begin
  1010.     glBegin(GL_QUADS);
  1011.     SetMaterial(Brush.Color);
  1012.     TeeNormal(0,0,z);
  1013.     TeeVertex3D(P1.X,P1.Y,Z);
  1014.     TeeVertex3D(P2.X,P2.Y,Z);
  1015.     TeeVertex3D(P3.X,P3.Y,Z);
  1016.     TeeVertex3D(P4.X,P4.Y,Z);
  1017.     TeeVertex3D(P1.X,P1.Y,Z);
  1018.     glEnd;
  1019.   end;
  1020. end;
  1021.  
  1022. procedure TGLCanvas.Plane3D(Const A,B:TPoint; Z0,Z1:Integer);
  1023. begin
  1024.   if Pen.Style<>psClear then
  1025.   begin
  1026.     glBegin(GL_LINE_LOOP);
  1027.     SetPenColor;
  1028.     TeeNormal(0,0,z0);
  1029.     TeeVertex3D(A.X,A.Y,Z0);
  1030.     TeeVertex3D(B.X,B.Y,Z0);
  1031.     TeeVertex3D(B.X,B.Y,Z1);
  1032.     TeeVertex3D(A.X,A.Y,Z1);
  1033.     glEnd;
  1034.   end;
  1035.   if Brush.Style<>bsClear then
  1036.   begin
  1037.     glBegin(GL_QUADS);
  1038.     TeeNormal(0,0,z0);
  1039.     SetMaterial(Brush.Color);
  1040.     TeeVertex3D(A.X,A.Y,Z0);
  1041.     TeeVertex3D(B.X,B.Y,Z0);
  1042.     TeeVertex3D(B.X,B.Y,Z1);
  1043.     TeeVertex3D(A.X,A.Y,Z1);
  1044.     glEnd;
  1045.   end;
  1046. end;
  1047.  
  1048. Function TGLCanvas.GetSupports3DText:Boolean;
  1049. begin
  1050.   result:=True;
  1051. end;
  1052.  
  1053. Function TGLCanvas.GetSupportsFullRotation:Boolean;
  1054. begin
  1055.   result:=True;
  1056. end;
  1057.  
  1058. Function TGLCanvas.GetTextAlign:TCanvasTextAlign;
  1059. begin
  1060.   result:=TA_LEFT;
  1061. end;
  1062.  
  1063. Function TGLCanvas.GetUseBuffer:Boolean;
  1064. begin
  1065.   result:=False;
  1066. end;
  1067.  
  1068. Procedure TGLCanvas.SetUseBuffer(Value:Boolean);
  1069. begin
  1070. end;
  1071.  
  1072. Function TGLCanvas.GetHandle:HDC;
  1073. begin
  1074.   result:=FDC;
  1075. end;
  1076.  
  1077. Procedure TGLCanvas.DoRectangle(Const Rect:TRect);
  1078. begin
  1079.   With Rect do Rectangle(Left,Top,Right,Bottom)
  1080. end;
  1081.  
  1082. Procedure TGLCanvas.DoHorizLine(X0,X1,Y:Integer);
  1083. begin
  1084.   MoveTo(X0,Y);
  1085.   LineTo(X1,Y);
  1086. end;
  1087.  
  1088. Procedure TGLCanvas.DoVertLine(X,Y0,Y1:Integer);
  1089. begin
  1090.   MoveTo(X,Y0);
  1091.   LineTo(X,Y1);
  1092. end;
  1093.  
  1094. procedure TGLCanvas.RotateLabel3D(x,y,z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF}; Const St:String; RotDegree:Integer);
  1095. begin
  1096.   RotateLabel(x,y,St,RotDegree);
  1097. end;
  1098.  
  1099. procedure TGLCanvas.RotateLabel(x,y:Integer; Const St:String; RotDegree:Integer);
  1100. begin
  1101.   TextOut(X,Y,St);
  1102. end;
  1103.  
  1104. Procedure TGLCanvas.Line(X0,Y0,X1,Y1:Integer);
  1105. begin
  1106.   MoveTo(X0,Y0);
  1107.   LineTo(X1,Y1);
  1108. end;
  1109.  
  1110. procedure TGLCanvas.EraseBackground(const Rect: TRect);
  1111. begin { nothing... }
  1112. end;
  1113.  
  1114. Procedure TGLCanvas.HorizLine3D(Left,Right,Y,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF});
  1115. begin
  1116.   MoveTo3D(Left,Y,Z);
  1117.   LineTo3D(Right,Y,Z);
  1118. end;
  1119.  
  1120. Procedure TGLCanvas.VertLine3D(X,Top,Bottom,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF});
  1121. begin
  1122.   MoveTo3D(X,Top,Z);
  1123.   LineTo3D(X,Bottom,Z);
  1124. end;
  1125.  
  1126. Procedure TGLCanvas.ZLine3D(X,Y,Z0,Z1:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF});
  1127. begin
  1128.   MoveTo3D(X,Y,Z0);
  1129.   LineTo3D(X,Y,Z1);
  1130. end;
  1131.  
  1132. Procedure TGLCanvas.Arrow( Filled:Boolean;
  1133.                            Const FromPoint,ToPoint:TPoint;
  1134.                            ArrowWidth,ArrowHeight,Z:Integer);
  1135. begin
  1136. end;
  1137.  
  1138. Procedure TGLCanvas.LineWithZ(X0,Y0,X1,Y1,Z:{$IFDEF D2C1}Longint{$ELSE}Integer{$ENDIF});
  1139. begin
  1140.   MoveTo3D(X0,Y0,Z);
  1141.   LineTo3D(X1,Y1,Z);
  1142. end;
  1143.  
  1144. procedure TGLCanvas.PolygonWithZ(const Points: array of TPoint; Z:Integer);
  1145. var t:Integer;
  1146. begin
  1147.   if Brush.Style<>bsClear then
  1148.   begin
  1149.     glBegin(GL_POLYGON);
  1150.     TeeNormal(0,0,1);
  1151.     SetMaterial(Brush.Color);
  1152.     for t:=Low(Points) to High(Points) do
  1153.       With Points[t] do TeeVertex3D( x, y, z);
  1154.     glEnd;
  1155.   end;
  1156.   if Pen.Style<>psClear then
  1157.   begin
  1158.     glBegin(GL_LINE_LOOP);
  1159.     TeeNormal(0,0,1);
  1160.     SetMaterial(Pen.Color);
  1161.     for t:=Low(Points) to High(Points) do
  1162.       With Points[t] do TeeVertex3D( x, y, z);
  1163.     glEnd;
  1164.   end;
  1165. end;
  1166.  
  1167. procedure TGLCanvas.TriangleWithZ(Const P1,P2,P3:TPoint; Z:Integer);
  1168. begin
  1169.   PolygonWithZ([P1,P2,P3],Z);
  1170. end;
  1171.  
  1172. Function TGLCanvas.GetBackMode:TCanvasBackMode;
  1173. begin
  1174.   result:=FBackMode;
  1175. end;
  1176.  
  1177. end.
  1178.